#ifndef ARTICLEMODEL_H
#define ARTICLEMODEL_H

#include "newspaper/categorydetail.h"
#include "newspaper/article.h"

#include <QObject>
#include <QAbstractListModel>
#include <QtQml/qqml.h>

class ArticleListModel : public QAbstractListModel
{
    Q_OBJECT
public:
    enum ArticleRoles {
        IdRole = Qt::UserRole + 1,
        ThumbnailImageRole,
        TitleRole,
        PostTimeRole,
        SourceArticleRole
    };

    ArticleListModel(QObject *parent = 0);

    void addArticleItem(Article* articleItem);

    void insertArticleItem(Article* articleItem, const int pos);

    int rowCount(const QModelIndex & parent = QModelIndex()) const;

    QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;

    void clear();

public slots:

    void setListArticle(const QList<Article*>& m_articleItems);

protected:
    QHash<int, QByteArray> roleNames() const;

    QList<Article*> m_articleItems;
};



QML_DECLARE_TYPE(ArticleListModel)

#endif // ARTICLEMODEL_H
